﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IRCServer.CommandHandlers;

namespace IRCServer.Entities.Commands
{
    class USERCommand: IRCCommandBase
    {
        public USERCommand(string message) : 
            base(message)

        {
            string[] parameters = Utilities.CommandParser.GetParameters(message);

            if (parameters.Length > 1)
            {
                this.Username = parameters[1];
            }

            if (parameters.Length > 2)
            {
                this.Hostname = parameters[2];
            }

            if (parameters.Length > 3)
            {
                this.Servername = parameters[3];
            }

            if (parameters.Length > 4)
            {
                this.Realname = parameters[4];
            }
        }

        public string Username { get; set; }

        public string Hostname { get; set; }

        public string Servername { get; set; }

        public string Realname { get; set; }


        public override string CommandName()
        {
            return "USER";
        }

        public override string ExecuteCommand(SessionBase session)
        {
            USERCommandHandler handler = new USERCommandHandler();
            return handler.HandleCommand(this, session);
        }
    }
}
